var fs = require('fs');
var path = require('path');

var sFilePath = path.join(__dirname,"/from.txt");
var dFilePath = path.join(__dirname,"/to.txt");
// 添加一个Readable并将读取到的数据转换后push到Readable中再pipe输出流
// var readable = new require("stream").Readable();   此方法暂时还没研究明白
var readStream = fs.createReadStream(sFilePath);
var writeStream = fs.createWriteStream(dFilePath);
readStream.on('data',function (mydata) {
    
    // console.log(data);
    mydata=mydata.toString('utf-8').toUpperCase();
    // console.log(mydata);
    // readable.push(mydata);

    
    writeStream.write(mydata);
    writeStream.end();
    
})
// readStream.on('end',function () {
//     
//     readable.pipe(writeStream);
//     
// })
